package com.jiyun.controller;

import com.jiyun.EmployeeFeign;
import com.jiyun.pojo.Duty;
import com.jiyun.pojo.Employee;
import com.jiyun.pojo.Sector;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("employee")
public class EmployeeController {

    @Autowired
    EmployeeFeign employeeFeign;


    @RequestMapping("findPage")
    @ResponseBody
    public List<Employee> findPage(){
        return employeeFeign.show();
    }
    @RequestMapping("del")
    public String del(Integer id){
          employeeFeign.del(id);
        return "employee";
    }
    @RequestMapping("show")
    public String show(){
        return "employee";
    }
    @RequestMapping("findzhi")
    @ResponseBody
    public List<Duty> findzhi(){
        return employeeFeign.findzhi();
    }

    @RequestMapping("findbu")
    @ResponseBody
    public List<Sector> findbu(){
        return employeeFeign.findbu();
    }

    @RequestMapping("add")
    public String add(@RequestBody Employee employee){
        employeeFeign.add(employee);
        return "employee";
    }

    @RequestMapping("update")
    public String update(@RequestBody Employee employee){
        employeeFeign.update(employee);
        return "employee";
    }

}
